package GameLogic
{
	import BasicEngine.Dispatcher;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.text.TextFormat;
	public class AlertTrace extends Sprite
	{
		public var msg:String;
		public var out:TextField;
		public var delay:int = 1000 * 2;
		public var delayCount:int = 0;
		public function AlertTrace(_msg:String)
		{
			msg = _msg;
			out = new TextField();
			out.text = _msg;
			out.width = msg.length * 30;
			var tf:TextFormat = new TextFormat();
			tf.size = 20;
			//tf.bold = true;
			tf.color = 0xff0000;
			out.setTextFormat(tf);
			//out.background = true;
			out.backgroundColor = 0xffffff;
			addChild(out);
			Game.Building.addChild(this);
			this.addEventListener(Event.ENTER_FRAME, Update);
			this.y = 20;
			this.x = 760;
			this.alpha = 0;
		}
		
		public function Update(e:Event):void
		{
		   this.x-=30;
		   this.alpha += 0.2;
		   if (this.x <= 250)
		      this.x = 250;
		   delayCount += Dispatcher.Clock.Tick;
		   if (delayCount > delay)
		   {
			   this.removeEventListener(Event.ENTER_FRAME, Update);
		       Game.Building.removeChild(this);
		   }
		}
		
		
		
		
	}
}